package com.py.payment.running;

import cn.hutool.cron.CronUtil;
import com.py.payment.nettys.config.SocketProperties;
import com.py.payment.nettys.server.NettyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.net.InetSocketAddress;

@Slf4j
@Component
public class NettyRunner implements CommandLineRunner {

    @Autowired
    private NettyServer nettyServer;

    @Autowired
    private SocketProperties socketProperties;

    @Override
    public void run(String... args) {
        InetSocketAddress address = new InetSocketAddress(socketProperties.getPort());
        log.info("netty服务器启动监听端口:"+socketProperties.getPort());
        nettyServer.start(address);
    }

}
